package edu.towson.cis.cosc442.project3.vendingmachine;

import static org.junit.Assert.*;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;

public class VendingMachineItemTest {
	VendingMachineItem testItem;
	
	/*
	 * testing constructor for VendingMachineItem
	 */
	@Before
	public void setUp(){
		 testItem = new VendingMachineItem("Skittles",1);
	}
	@Test
	public void testVendingMachineItem() {
		VendingMachineItem testItemA = new VendingMachineItem("Panda",2);
		assertTrue(testItemA.getName()!= null);
		assertTrue(testItemA.getPrice()>=0);
		
	}

	/*
	 * testing getName for VendingMachineItem
	 */
	@Test
	public void testGetName() {
		assertTrue(testItem.getName().equals("Skittles"));
		
	}

	/*
	 * testing getPrice for VendingMachineItem
	 */
	@Test
	public void testGetPrice() {
		assertTrue(testItem.getPrice()== 1);
	}

	/*
	 * Tests if exception is thrown when cost of item is put to less than 0
	 */
	@Test(expected = VendingMachineException.class)
	public void testPriceLessThanZeroException() throws VendingMachineException {
	    testItem = new VendingMachineItem("apple",-1);
	}
	/*
	 * method to test the equals method that I added to the program
	 * when equal
	 */
	@Test
	public void testVendingMachineItemEquals(){
		VendingMachineItem testItemB = new VendingMachineItem("Skattles",1);
		assertTrue(testItemB.equals(testItem));
	}
	/*
	 * method to test the equals method that I added to the program
	 * correctly returns false when unequal
	 */
	@Test
	public void testVendingMachineItemNotEquals(){
		VendingMachineItem testItemB = new VendingMachineItem("Skittles",1);
		assertTrue(testItemB.equals(testItem));
	}
	@After
	public void tearDown(){
		testItem = null;
	}


}
